#include "mainexeqtor.h"

MainExeqtor::MainExeqtor(Session* context)
{
    this->context=context;
    Init();
}

void MainExeqtor::executeCurrent(Para* command)
{
    if (command->getName() != "error")
        execDict.value(command->getName())->execute(command);
    else
    {
        //todo error handle
    }
}

executor* MainExeqtor::getCurrent(QString name)
{
    return execDict.value(name);
}

void MainExeqtor::Init()
{
    execDict.insert("authorization", new AuthorizationExecutor(context));
    execDict.insert("editRoom", new EditRoomExecutor(context));
    execDict.insert("getMessages", new GetMessagesExecutor(context));
    execDict.insert("getUsers", new GetUsersExecutor(context));
    execDict.insert("joinRoom", new JoinRoomExecutor(context));
    execDict.insert("leave", new LeaveExecutor(context));
    execDict.insert("profile", new ProfileExecutor(context));
    execDict.insert("register", new RegistrationExecutor(context));
    execDict.insert("roomsList", new RoomsListExecutor(context));
    execDict.insert("sendMessage", new SendMessageExecutor(context));
    execDict.insert("setRule", new SetRuleExecutor(context));
    execDict.insert("update", new UpdateExecutor(context));
}
